[MDEV-7356] Subquery gives incorrect results Created: 2014-12-21 Updated: 2015-02-17 Resolved: 2015-02-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Subquery, Optimizer |
| Affects Version/s: | 5.3.12, 5.5, 10.0 |
| Fix Version/s: | 5.5.43 |
| Type: | Bug | Priority: | Critical |
| Reporter: | TaoXu | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Arch Linux |
||
| Description |
|
I have two SQL statements that is logically identical but MariaDB give different results.
2.
The table contents are as below:
way_types have only one row:
DDLs for table are as below:
|
| Comments |
| Comment by TaoXu [ 2014-12-21 ] | ||||||||||||||||||||||
|
@Elena Stepanova, thank you for formatting the code, now the preview looks great! | ||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-12-21 ] | ||||||||||||||||||||||
|
Thanks for the report and the test case. | ||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-12-21 ] | ||||||||||||||||||||||
|
Here is an MTR test case simplified just a little further.
EXPLAIN:
| ||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-17 ] | ||||||||||||||||||||||
|
Debugging execution, one can see that way_types and way_tags_test do not have an attached WHERE clause. IN-equality way_tags_test.v = way_types.type is not checked anywhere. | ||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-17 ] | ||||||||||||||||||||||
|
The condition is in join->conds, make_join_select() correctly attaches it to table way_tags_test:
but then, this code removes it :
| ||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-02-17 ] | ||||||||||||||||||||||
|
Ok, the check in remove_sj_conds() / is_cond_sj_in_equality() seems to be incorrect. The check intends to remove IN-equalities from subquery's join tabs (We cant check them, as they refer to outside tables. Outside table fields are not available when one is doing materialization). However, the check returns true for the IN-equality of the grand-child subquery, which has been merged into the child subquery. |