[MDEV-3574] LP:951283 - Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery Created: 2012-03-10 Updated: 2015-02-02 Resolved: 2012-10-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Elena Stepanova | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
The following query SELECT * FROM t1 AS alias1, t1 AS alias2, t2 AS alias3 on test data returns 2940 rows if it is executed with semijoin=on, firstmatch=on, optimizer_prune_level=0, and 3724 rows otherwise. The latter is correct. bzr version-info Also reproducible on MariaDB 5.5 (revno 3316). Not reproducible on MySQL 5.6 (revno 3706). EXPLAIN with semijoin=on, firstmatch=on, optimizer_prune_level=0 (wrong result): id select_type table type possible_keys key key_len ref rows filtered Extra EXPLAIN with semijoin=on, firstmatch=on, optimizer_prune_level=1 (correct result): id select_type table type possible_keys key key_len ref rows filtered Extra Minimal optimizer_switch: firstmatch=on,semijoin=on Test case: --source include/have_innodb.inc SET optimizer_switch='firstmatch=on,semijoin=on'; CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; CREATE TABLE t2 ( INSERT INTO t2 VALUES SELECT COUNT
|
| Comments |
| Comment by Elena Stepanova [ 2012-03-10 ] |
|
Re: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery |
| Comment by Sergei Petrunia [ 2012-03-11 ] |
|
Re: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery I've compared the query output resultsets:
|
| Comment by Sergei Petrunia [ 2012-03-11 ] |
|
Re: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery O alias3 Here "O" means outer, "I" means inner, "n" - outer, not correlated with the subquery table. When I debug to see why records with alias3.b=6 do not make it to the output, I see this scenario:
if (join->return_tab < join_tab) Apparently, FirstMatch code is malfunctioning when it is handling the case where inner tables are interleaved with outer tables. |
| Comment by Sergei Petrunia [ 2012-03-26 ] |
|
Re: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery |
| Comment by Sergei Petrunia [ 2012-03-26 ] |
|
Alternate proposal: unfinished patch and exploration |
| Comment by Rasmus Johansson (Inactive) [ 2012-04-03 ] |
|
Launchpad bug id: 951283 |