mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
Fixed LP bug #899777.
KEYUSE elements for a possible hash join key are not sorted by field numbers of the second table T of the hash join operation. Besides some of these KEYUSE elements cannot be used to build any key as their key expressions depend on the tables that are planned to be accessed after the table T. The code before the patch did not take this into account and, as a result, execition of a query the employing block-based hash join algorithm could cause a crash or return a wrong result set.
This commit is contained in:
parent
b5a05df61e
commit
7d1f41265c
4 changed files with 135 additions and 14 deletions
|
|
@ -3254,5 +3254,45 @@ SET optimizer_switch=@tmp887479_optimizer_switch;
|
|||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #899777: join_cache_level=4 + semijoin=on
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int, b int, c int, UNIQUE INDEX idx (a));
|
||||
INSERT INTO t1 VALUES (1,8,6), (2,2,8);
|
||||
CREATE TABLE t2 (a int, b int, c int, UNIQUE INDEX idx (a));
|
||||
INSERT INTO t2 VALUES (1,8,6), (2,2,8);
|
||||
CREATE TABLE t3 (a int, b int, c int, UNIQUE INDEX idx (a));
|
||||
INSERT INTO t3 VALUES (1,8,6), (2,2,8);
|
||||
CREATE TABLE t4 (a int, b int, c int, UNIQUE INDEX idx (a));
|
||||
INSERT INTO t4 VALUES (1,8,6), (2,2,8);
|
||||
|
||||
SET @tmp_optimizer_switch=@@optimizer_switch;
|
||||
SET SESSION optimizer_switch='semijoin=on';
|
||||
SET SESSION optimizer_switch='semijoin_with_cache=on';
|
||||
|
||||
SET SESSION join_cache_level=1;
|
||||
EXPLAIN
|
||||
SELECT t1.* FROM t1,t2
|
||||
WHERE (t1.b,t2.b) IN (SELECT t3.b,t4.b FROM t3,t4 WHERE t4.c=t3.b)
|
||||
AND t1.a = 1;
|
||||
SELECT t1.* FROM t1,t2
|
||||
WHERE (t1.b,t2.b) IN (SELECT t3.b,t4.b FROM t3,t4 WHERE t4.c=t3.b)
|
||||
AND t1.a = 1;
|
||||
|
||||
SET SESSION join_cache_level=4;
|
||||
EXPLAIN
|
||||
SELECT t1.* FROM t1,t2
|
||||
WHERE (t1.b,t2.b) IN (SELECT t3.b,t4.b FROM t3,t4 WHERE t4.c=t3.b)
|
||||
AND t1.a = 1;
|
||||
SELECT t1.* FROM t1,t2
|
||||
WHERE (t1.b,t2.b) IN (SELECT t3.b,t4.b FROM t3,t4 WHERE t4.c=t3.b)
|
||||
AND t1.a = 1;
|
||||
|
||||
SET SESSION join_cache_level = DEFAULT;
|
||||
SET optimizer_switch=@tmp_optimizer_switch;
|
||||
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
|
||||
# this must be the last command in the file
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue