1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fixed LP bug #817360.

This problem could be observed for queries with nested outer joins
for which the not_exist optimization were applicable. 
The problem was caused by the code of the patch for bug #49322
that erroneously forced the return to the previous nested loop
level when the join algorithm successfully builds a partial record
for an embedded outer to which the not_exist optimization could be
applied.
Actually the immediate return to the previous nested loops level
is correct only if this partial record is rejected by a predicate
pushed down to one of the inner tables of this outer join. Otherwise
attempts to find extensions of this record must be made.
This commit is contained in:
Igor Babaev
2011-07-29 17:09:16 -07:00
parent cfa08e8dad
commit 103c4461ca
4 changed files with 100 additions and 6 deletions

View File

@ -1801,4 +1801,35 @@ pk a pk a pk a
7 NULL NULL NULL NULL NULL
8 9 NULL NULL NULL NULL
DROP TABLE t1, t2, t3;
CREATE TABLE t1 (a int NOT NULL );
INSERT INTO t1 VALUES (9), (9);
CREATE TABLE t2 (a int NOT NULL );
INSERT INTO t2 VALUES (9);
CREATE TABLE t3 (a int NOT NULL, b int);
INSERT INTO t3 VALUES (19,9);
CREATE TABLE t4 (b int) ;
SELECT * FROM t1 LEFT JOIN
((t2 LEFT JOIN t3 ON t2.a=t3.b) LEFT JOIN t4 ON t3.a=t4.b)
ON t1.a=t2.a;
a a a b b
9 9 19 9 NULL
9 9 19 9 NULL
SELECT * FROM t1 LEFT JOIN
((t2 LEFT JOIN t3 ON t2.a=t3.b) LEFT JOIN t4 ON t3.a=t4.b)
ON t1.a=t2.a
WHERE t3.a IS NULL;
a a a b b
EXPLAIN EXTENDED
SELECT * FROM t1 LEFT JOIN
((t2 LEFT JOIN t3 ON t2.a=t3.b) LEFT JOIN t4 ON t3.a=t4.b)
ON t1.a=t2.a
WHERE t3.a IS NULL;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where; Not exists
1 SIMPLE t4 ALL NULL NULL NULL NULL 0 0.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on(((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`b` = `test`.`t1`.`a`))) left join `test`.`t4` on((`test`.`t4`.`b` = `test`.`t3`.`a`))) on((`test`.`t2`.`a` = `test`.`t1`.`a`)) where isnull(`test`.`t3`.`a`)
DROP TABLE t1,t2,t3,t4;
End of 5.0 tests