Commit 2837ba5
Dag Wanvik
Bug#36307622 [back-port] Wrong result from query with WHERE integer IN (SELECT 2 EXCEPT SELECT 4)
A work-around is to set the optimizer flag to not use hash map
de-duplication for INTERSECT, EXCEPT, like so:
SET optimizer_switch="hash_set_operations=off";
With hash_set_operations enabled, however, we get too may result rows.
For the IN predicate, the set operation is computed repeatedly, with
filters pushed down to set set operation operands:
-> Filter: <in_optimizer>(c.pk,<exists>(select #2)) (cost=2.25 rows=20)
-> Covering index scan on c using idx_c_col_datetime_key (cost=2.25 rows=20)
-> Select #2 (subquery in condition; dependent)
-> Limit: 1 row(s) (cost=2.61..2.61 rows=1)
-> Table scan on <except temporary> (cost=2.61..2.61 rows=1)
-> Except materialize with deduplication (cost=0.1..0.1 rows=1)
-> Filter: (<cache>(c.pk) = <ref_null_helper>(2)) (cost=0..0 rows=1)
-> Rows fetched before execution (cost=0..0 rows=1)
-> Filter: (<cache>(c.pk) = <ref_null_helper>(4)) (cost=0..0 rows=1)
-> Rows fetched before execution (cost=0..0 rows=1)
Only the row with pk==2 should pass the filters under the except node, and that's
what happens. However, on repeated execution, the hash map used to implement
the Except materialize is not re-initialized to being empty.
The patch adds reinitialization of the hash map for such cases.
Change-Id: Idf2e36f9085e36748900017a0aad420e4e476f781 parent 5969f18 commit 2837ba5
File tree
3 files changed
+93
-13
lines changed- mysql-test
- r
- t
- sql/iterators
3 files changed
+93
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
621 | 628 | | |
622 | 629 | | |
623 | 630 | | |
| |||
876 | 883 | | |
877 | 884 | | |
878 | 885 | | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | 886 | | |
891 | 887 | | |
892 | 888 | | |
| |||
1385 | 1381 | | |
1386 | 1382 | | |
1387 | 1383 | | |
1388 | | - | |
1389 | | - | |
1390 | 1384 | | |
1391 | 1385 | | |
1392 | 1386 | | |
| |||
1445 | 1439 | | |
1446 | 1440 | | |
1447 | 1441 | | |
| 1442 | + | |
1448 | 1443 | | |
1449 | 1444 | | |
1450 | 1445 | | |
| |||
1576 | 1571 | | |
1577 | 1572 | | |
1578 | 1573 | | |
| 1574 | + | |
1579 | 1575 | | |
1580 | 1576 | | |
1581 | 1577 | | |
| |||
1976 | 1972 | | |
1977 | 1973 | | |
1978 | 1974 | | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
1979 | 1983 | | |
1980 | 1984 | | |
1981 | 1985 | | |
| |||
0 commit comments