[MDEV-11936] Wrong Results with User Vars in derived tables with WHERE Created: 2017-01-29 Updated: 2022-12-08 Resolved: 2022-12-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Subquery, Optimizer |
| Affects Version/s: | 10.2.3 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Bernd Buffen | Assignee: | Sergei Petrunia |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Environment: |
MAC OS |
||
| Description |
|
When i use a user variable in a query, only to count the rows is every thing ok. When i put this select as derived table it also look OK. When i now add WHERE clause in the outer SELECT the count is wrong. I have simplify a sample. in version 10.1 is the result ok The Table
The Rows
Easy Select
SELECT with derived table
Now with WHERE and error
And also = dosent work (empty result)
|
| Comments |
| Comment by Elena Stepanova [ 2017-02-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I am not sure that the scenario as such is guaranteed to work, but the behavior changed between 10.1 and 10.2, and there is a difference in execution plans which at the very least least needs to be looked at and confirmed to be intentional.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-02-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re-formatted outputs of SHOW WARNINGS: 10.1:
10.2:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-02-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This looks to be an effect of "condition pushdown into non-mergeable views" optimization. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-02-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Will discuss on next optimizer call if this can/should be fixed. It is not clear for me what the optimizer promises are with regards to computing @variable:=... expressions and the rest of WHERE. As for numbering rows, 10.2 has a new way to do it - window functions and ROW_NUMBER() function in particular. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2022-12-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Current 10.3 d360fa6fa897d9556dc3813-10.11 return expected result:
|