Wrong result with materialization and NOT IN with 2 expressions
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| MariaDB |
Fix Released
|
Critical
|
Timour Katchaounov | ||
Bug Description
The following query:
SELECT *
FROM t1
WHERE (a, b ) NOT IN (
SELECT a , b
FROM t2
);
does not return any rows when executed with materialization, even though it should return
a | b
---+---
4 | 4
4 | 2
(2 rows)
explain:
| 1 | PRIMARY | t1 | ALL | NULL | NULL | NULL | NULL | 2 | Using where |
| 2 | SUBQUERY | t2 | ALL | NULL | NULL | NULL | NULL | 2 | |
minimal optimizer switch: in_to_exists=
full optimizer_switch:
index_merge=
test case:
CREATE TABLE t1 (a int,b int);
INSERT INTO t1 VALUES (4,4),(4,2);
CREATE TABLE t2 (b int, a int);
INSERT INTO t2 VALUES (4,3),(8,4);
SET SESSION optimizer_
SELECT *
FROM t1
WHERE (a, b ) NOT IN (
SELECT a , b
FROM t2
);
Repeatable in maria-5.3. Not repeatable in maria-5.2, mysql-5.5 . Does not involve NULLs, empty tables, empty subqueries or constant tables. Seems the particular values in the tables are significant.
| Changed in maria: | |
| milestone: | none → 5.3 |
| Changed in maria: | |
| status: | New → Confirmed |
| importance: | Undecided → Critical |
| assignee: | nobody → Timour Katchaounov (timour) |
| Changed in maria: | |
| status: | Confirmed → In Progress |
| description: | updated |
| Changed in maria: | |
| status: | Confirmed → In Progress |
| Changed in maria: | |
| status: | In Progress → Fix Committed |
| Changed in maria: | |
| status: | Fix Committed → Fix Released |

I have no idea how did I reproduce this bug. I tried with several
revisions of 5.3 all the way back to the end of June, and was not able
to reproduce it.
Philip, please let me know if I missed something.