Wrong result with semijoin + materialization + firstmatch + multipart key
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
High
|
Sergey Petrunia |
Bug Description
The following query:
SELECT *
FROM t1 JOIN t2 ON (t2.f4 = t1.f3 )
WHERE ( 8 ) IN (
SELECT t3.f1 FROM t3 , t4
);
returns 1 row when executed with materialization
+------
| f2 | f3 | f4 |
+------
| NULL | x | x |
+------
even though it should return 2 rows:
+------
| f2 | f3 | f4 |
+------
| 8 | x | x |
| NULL | x | x |
+------
explain:
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-
| 1 | PRIMARY | t2 | ALL | NULL | NULL | NULL | NULL | 1 | Using where |
| 1 | PRIMARY | t1 | ref | f3 | f3 | 4 | test.t2.f4 | 1 | Using index |
| 1 | PRIMARY | t4 | ALL | NULL | NULL | NULL | NULL | 3 | |
| 1 | PRIMARY | t3 | ALL | NULL | NULL | NULL | NULL | 5 | Using where; FirstMatch(t2) |
minimal switch:
materialization
full switch:
index_merge=
test case:
SET SESSION optimizer_
CREATE TABLE t1 ( f2 int, f3 varchar(1), KEY (f3,f2)) ;
INSERT INTO t1 VALUES (8,'x')
CREATE TABLE t2 ( f4 varchar(1)) ;
INSERT INTO t2 VALUES ('x');
CREATE TABLE t3 ( f1 int) ;
INSERT INTO t3 VALUES (8),(6)
CREATE TABLE t4 ( f3 varchar(1)) ;
INSERT INTO t4 VALUES ('p'),('j'),('c');
SELECT *
FROM t1 JOIN t2 ON (t2.f4 = t1.f3 )
WHERE ( 8 ) IN (
SELECT t3.f1 FROM t3 , t4
);
revision-id: <email address hidden>
date: 2011-10-06 01:21:15 +0400
build-date: 2011-10-06 12:04:17 +0300
revno: 3213
branch-nick: maria-5.3
Changed in maria: | |
milestone: | none → 5.3 |
assignee: | nobody → Sergey Petrunia (sergefp) |
Changed in maria: | |
importance: | Undecided → High |
Changed in maria: | |
status: | New → Incomplete |
Changed in maria: | |
status: | New → Confirmed |
Changed in maria: | |
status: | Confirmed → Fix Committed |
Changed in maria: | |
status: | Fix Committed → Fix Released |
Not repeatable on work.askmonty.org with tip cset:
revno: 3200
revision-id: <email address hidden>
and debug build.