Wrong result with nested IN and singlerow subqueries and equality propagation
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| MariaDB |
Fix Released
|
High
|
Timour Katchaounov | ||
Bug Description
The following query:
SELECT * FROM t2
WHERE t2.b IN (
SELECT b
FROM t3
WHERE t3.a = t2.a
AND a < SOME (SELECT * FROM t4)
) OR ( t2.c > 242 );
returns no rows. Expected result:
+------
| c | a | b |
+------
| 10 | 7 | 0 |
+------
explain:
+----+-
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-
| 1 | PRIMARY | t2 | system | NULL | NULL | NULL | NULL | 1 | |
| 2 | DEPENDENT SUBQUERY | t3 | ALL | NULL | NULL | NULL | NULL | 2 | Using where |
| 3 | SUBQUERY | t4 | ALL | NULL | NULL | NULL | NULL | 2 | |
+----+-
3 rows in set (0.00 sec)
Not influenced by any particular switch. full optimizer_switch:
index_merge=
bzr version-info:
revision-id: <email address hidden>
date: 2011-08-23 15:51:47 +0300
build-date: 2011-08-25 14:52:56 +0300
revno: 3166
branch-nick: maria-5.3
test case:
CREATE TABLE t2 ( c int , a int, b int);
INSERT INTO t2 VALUES (10,7,0);
CREATE TABLE t3 ( a int, b int) ;
INSERT INTO t3 VALUES (5,0),(7,0);
CREATE TABLE t4 (a int);
INSERT INTO t4 VALUES (2),(8);
SELECT * FROM t2
WHERE t2.b IN (
SELECT b
FROM t3
WHERE t3.a = t2.a
AND a < SOME (SELECT * FROM t4)
) OR ( t2.c > 242 );
Reproducible with maria-5.3. Not reproducible with maria 5.2, mysql-5.5. Does not involve NULLS, empty or constant tables.
Related branches
| Changed in maria: | |
| milestone: | none → 5.3 |
| Changed in maria: | |
| assignee: | Sergey Petrunia (sergefp) → Timour Katchaounov (timour) |
| Changed in maria: | |
| status: | New → Confirmed |
| importance: | Undecided → High |
| Changed in maria: | |
| status: | Confirmed → In Progress |
| summary: |
- Wrong result with nested correlated subqueries, OR condition + Wrong result with nested IN and singlerow subqueries and equality + propagation |
| Changed in maria: | |
| status: | In Progress → Fix Released |

The problem can be still repeated when one has set optimizer_ switch= 'semijoin= off' or 'materializatio n=off', or both.
Seems to be a generic subquery code problem.