Wrong result with semijoin=on, outer join in maria-5.3-subqueries-mwl90
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Invalid
|
High
|
Sergey Petrunia |
Bug Description
Repeatable on maria-5.3-mwl90. Not repeatable in maria-5.3 due to a different query plan.
The following query:
SELECT alias2.f1
FROM t2 AS alias1
LEFT JOIN ( t1 AS alias2 JOIN t1 AS alias3 ON alias3.f2 = alias2.f3 )
ON alias3.f2 = alias2.f2
WHERE alias2.f1 IN ( SELECT f1 FROM t2 AS alias4 ) ;
returns no rows when executed with semijoin=on in maria-5.
Explain in maria-5.
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 Start temporary
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
1 PRIMARY alias2 ALL NULL NULL NULL NULL 3 Using where; End temporary
1 PRIMARY alias3 ALL NULL NULL NULL NULL 3 Using where
explain in maria-5.3:
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
1 PRIMARY alias2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 PRIMARY alias3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
2 DEPENDENT SUBQUERY alias4 ALL NULL NULL NULL NULL 2 Using where
bzr version-info:
revision-id: <email address hidden>
date: 2011-06-28 18:25:02 +0400
build-date: 2011-06-29 09:45:49 +0300
revno: 3066
branch-nick: maria-5.
optimizer_switch in effect:
index_merge=
test case:
SET SESSION optimizer_switch = 'semijoin=
CREATE TABLE t2 ( f1 int) ;
INSERT IGNORE INTO t2 VALUES (6),(8);
CREATE TABLE t1 ( f1 int, f2 int, f3 int) ;
INSERT IGNORE INTO t1 VALUES (8,0,0)
SELECT alias2.f1
FROM t2 AS alias1
LEFT JOIN ( t1 AS alias2 JOIN t1 AS alias3 ON alias3.f2 = alias2.f3 )
ON alias3.f2 = alias2.f2
WHERE alias2.f1 IN ( SELECT f1 FROM t2 AS alias4 ) ;
Related branches
Changed in maria: | |
assignee: | nobody → Sergey Petrunia (sergefp) |
milestone: | none → 5.3 |
Changed in maria: | |
importance: | Undecided → High |
Another example:
CREATE TABLE t1 ( f10 int) ;
INSERT INTO t1 VALUES (0),(0);
CREATE TABLE t2 ( f10 int, f11 varchar(1)) ;
INSERT INTO t2 VALUES (0,'a'),(0,'b');
CREATE TABLE t3 ( f10 int) ; ,(0),(0) ,(0);
INSERT INTO t3 VALUES (0),(0)
CREATE TABLE t4 ( f10 varchar(1), f11 int) ;
INSERT INTO t4 VALUES ('a',0),('b',0);
SELECT * FROM t1
LEFT JOIN ( t2 JOIN t3 ON t3.f10 = t2.f10 ) ON t1.f10 = t2.f10
WHERE t2.f10 IN (
SELECT t4.f11
FROM t4
WHERE t4.f10 != t2.f11
);