[MDEV-4173] Wrong result (extra row) with semijoin=on, joins in outer query, LEFT JOIN in the subquery Created: 2013-02-15 Updated: 2013-07-16 Resolved: 2013-07-16 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.0.1, 5.5.29 |
| Fix Version/s: | 10.0.4, 5.5.32 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||
| Description |
|
The following test case produces COUNT = 23712 when it is executed with exists_to_in=off, and 23713 when it is executed with exists_to_in=on. Test case:
Result with exists_to_in=off:
Result with exists_to_in=on:
EXPLAIN with exists_to_in=on, otherwise default optimizer_switch:
|
| Comments |
| Comment by Oleksandr Byelkin [ 2013-02-18 ] |
|
Plan chosen for exist2in then semi-join is 3-4 times worse then usual subquery execution. |
| Comment by Oleksandr Byelkin [ 2013-02-19 ] |
|
It looks like a semi-join problem... SELECT COUNT |
| Comment by Oleksandr Byelkin [ 2013-02-19 ] |
|
new test suite: CREATE TABLE t2 (i2 INT, j2 INT); CREATE TABLE t3 (i3 INT, KEY(i3)); SELECT COUNT |
| Comment by Patryk Pomykalski [ 2013-05-15 ] |
|
I think its something with join cache. |
| Comment by Patryk Pomykalski [ 2013-05-16 ] |
|
Also on 5.3: CREATE TABLE t1 (i1 INT) engine=myisam; CREATE TABLE t2 (i2 INT, j2 INT) engine=myisam; CREATE TABLE t3 (i3 INT, KEY(i3)) engine=myisam; set max_heap_table_size=16*1024; --disable_query_log Tested on 32bit machine outputs: |
| Comment by Patryk Pomykalski [ 2013-05-17 ] |
|
This bug is since 5.3.0 |
| Comment by Patryk Pomykalski [ 2013-05-19 ] |
|
I have analyzed and fixed this. The problem was due to ignoring overflowing duplicate value when converting from heap to aria/myisam temp table. Patch for 5.3 branch: |
| Comment by Sergei Petrunia [ 2013-07-13 ] |
|
Confirm Patryk's analysis. Apparently, DuplicateElimination strategy is the only part of SQL layer that cares about whether a write to temporary table resulted in HA_ERR_DUPP_KEY or not. The patch seems big, but most of the changes are trivial. MySQL 5.6 also has such change. They have introduced it as a part of some big patch. |
| Comment by Sergei Petrunia [ 2013-07-15 ] |
|
Patryk, can I assume that the patch you've posted above is available to MariaDB under the New BSD licence? |
| Comment by Patryk Pomykalski [ 2013-07-15 ] |
|
Yes, all my patches are available under New BSD license. This one is mostly from mysql code. |
| Comment by Sergei Petrunia [ 2013-07-16 ] |
|
Thanks. |