[MDEV-15035] Wrong results when calling a stored procedure multiple times with different arguments Created: 2018-01-22 Updated: 2018-07-26 Resolved: 2018-04-27 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer, Stored routines |
| Affects Version/s: | 5.5, 10.0, 10.1, 10.2.12, 10.2 |
| Fix Version/s: | 5.5.61 |
| Type: | Bug | Priority: | Major |
| Reporter: | Simeon Maxein | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | stored_procedures, wrong_result | ||
| Environment: |
Ubuntu Xenial, 64-Bit |
||
| Description |
|
When calling the same stored procedure multiple times with different arguments over the course of a single connection, the later calls may return wrong result sets. The following example illustrates the issue. First, some setup:
Now, create a new connection to the DBMS and run the following statements:
I get one result row for each statement (with the content id=1). However, the second statement should return two rows (1 and 2). Create a new connection again, and run the following:
When I do that, I get the correct result (1 and 2). Running any further sequence of the above two statements on that same connection appears to yield the correct results as well (e.g. if we follow with CALL test_proc(0); and then CALL test_proc(1); again, it will still return the correct rows 1 and 2). Note: This is probably the same issue described in this StackOverflow question: https://stackoverflow.com/questions/43363500/mysql-inconsistent-query-results-in-procedure-with-temp-tables-empty-resultset |
| Comments |
| Comment by Simeon Maxein [ 2018-01-23 ] | ||||||||||||||||||||||||||||||||
|
This is just guesswork from playing around with this trying to find a workaround, but it feels to me like
I can work around the problem by replacing b.id IS NOT NULL with IF(b.id IS NOT NULL, 1, 0), which probably prevents the optimizer from understanding that it can use an inner join. | ||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2018-01-24 ] | ||||||||||||||||||||||||||||||||
|
Thanks for the report and testcase!
| ||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2018-04-25 ] | ||||||||||||||||||||||||||||||||
|
OK to push! | ||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2018-04-27 ] | ||||||||||||||||||||||||||||||||
|
A fix for this bug was pushed into 5.5. |