Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-17189

Session variable initialization

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Not a Bug
    • 10.3.9
    • N/A
    • Stored routines, Variables
    • None
    • Linux CentOs x64

    Description

      It seems as if session variables in stored procedures are not necessarily initialized with 'NULL' on 'BEGIN'.
      Example:

      CREATE PROCEDURE UPSERT_CloudGroupUserMap(
      IN inGroupName text,
      OUT outID int)
      proc: BEGIN

      SELECT GroupID INTO @GroupId
      FROM CloudGroups
      WHERE Name = inGroupName;

      SET outStatus = @GroupId;
      LEAVE proc;
      END;

      If the query does not return any rows (because the 'Name' does not match), the variable '@GroupId' contains the result of the previous query, instead of 'NULL' which I'd expect.

      Workaround:
      SET @GroupId = NULL;
      before the query.

      Any Ideas why this might happen?

      Attachments

        Activity

          People

            Unassigned Unassigned
            Klyse Klaus PrĂ¼nster
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.