[MDEV-17189] Session variable initialization Created: 2018-09-13 Updated: 2018-09-25 Resolved: 2018-09-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Stored routines, Variables |
| Affects Version/s: | 10.3.9 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | Klaus Prünster | Assignee: | Unassigned |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux CentOs x64 |
||
| Description |
|
It seems as if session variables in stored procedures are not necessarily initialized with 'NULL' on 'BEGIN'. CREATE PROCEDURE UPSERT_CloudGroupUserMap( SELECT GroupID INTO @GroupId SET outStatus = @GroupId; 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: Any Ideas why this might happen? |
| Comments |
| Comment by Alice Sherepa [ 2018-09-17 ] |
|
@GroupId here is user-defined variable, it exists until the session will be closed, so it contains previous results. |
| Comment by Klaus Prünster [ 2018-09-17 ] |
|
@Alice Sherepa $inst = new mysqli($host, $user, $pass, $name); So in my understanding, my code should actually create a session for each element in the for each, correct? |
| Comment by Alice Sherepa [ 2018-09-24 ] |
|
AFAIU your code creates a connection to the server and then for each $group it sends a set of queries (sets variables and calls procedure), so all this inside the same connection. |
| Comment by Klaus Prünster [ 2018-09-25 ] |
|
Okay, now I understand that. Thanks! |