Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Not a Bug
-
10.3.9
-
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?