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

Session variable initialization

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Not a Bug
    • Affects Version/s: 10.3.9
    • Fix Version/s: N/A
    • Component/s: Stored routines, Variables
    • Labels:
      None
    • Environment:
      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

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

              Dates

              Created:
              Updated:
              Resolved: