[MDEV-5034] Wrong result on LEFT JOIN with a SELECT SQ or a merge view, UNION in IN subquery Created: 2013-09-18 Updated: 2013-10-11 Resolved: 2013-10-10 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.0.4, 5.5.33, 5.3.12 |
| Fix Version/s: | 5.5.34, 10.0.6, 5.3.13 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Oleksandr Byelkin |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||
| Description |
|
The problem appeared on 5.3 tree with the following revision:
Actual result:
Expected result:
Also reproducible with a subquery instead of the view, in this case derived_merge=on is required. MariaDB 5.2 and MySQL 5.6 return the correct result. |
| Comments |
| Comment by Elena Stepanova [ 2013-10-09 ] |
|
Here is another test case, it's very similar to the initial one, but might be somewhat simpler as it doesn't require a subquery with UNION under IN: CREATE TABLE t1 (a INT, b VARCHAR(1), INDEX(b,a)); CREATE TABLE t2 (c VARCHAR(1), INDEX(c)); CREATE ALGORITHM=MERGE VIEW v AS SELECT t1a.* FROM t1, t1 AS t1a; CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v AS SELECT t1a.* FROM t1, t1 AS t1a; |
| Comment by Oleksandr Byelkin [ 2013-10-09 ] |
|
To find table on which we should check NULL Item_direct_view_ref::check_null_ref gets the left most real table of the VIEW or derived table (get_real_join_table()) and get unused table which probably do net update status correctly (if change order of the tables in the view or in the derived table bug will disappear). The problem now how to find correct table in the all leaf tables of the view or of the derived table. |
| Comment by Oleksandr Byelkin [ 2013-10-09 ] |
|
Above maybe wrong because mark_as_null_row was really called twice for both tables. |
| Comment by Oleksandr Byelkin [ 2013-10-10 ] |
|
The problem is that reading first record (by index) in the left part of left join returns no more record (as if table is empty). Everything else goes from this. |
| Comment by Oleksandr Byelkin [ 2013-10-10 ] |
|
mark_as_null_row applied to both tables under left join when sub_select drop flag only for one table |
| Comment by Oleksandr Byelkin [ 2013-10-10 ] |
|
duplicate of |