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

Merge fix for BUG#877288

This commit is contained in:
Sergey Petrunya
2011-10-26 10:58:40 +04:00
4 changed files with 83 additions and 1 deletions

View File

@ -1963,4 +1963,35 @@ ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your W
set max_join_size= @tmp_mjs_861147;
set optimizer_switch= @tmp_os_861147;
DROP TABLE t1,t2,t3,t4,t5,t6;
#
# BUG#877288: Wrong result with semijoin + materialization + multipart key
#
set @tmp_877288=@@optimizer_switch;
set optimizer_switch='semijoin=ON,materialization=ON';
CREATE TABLE t1 ( a int) ;
INSERT INTO t1 VALUES (19),(19),(19),(20),(20),(20),(20),(20),(20);
CREATE TABLE t2 ( b int NOT NULL , c int NOT NULL , KEY (b,c)) ;
INSERT INTO t2 VALUES (14,1),(15,1),(16,1),(17,1),(18,1),(19,1),(20,1);
CREATE TABLE t3 ( a int, d int) ;
INSERT INTO t3 VALUES (19,1),(7,1),(3,1),(3,1),(20,1),(3,1),(16,1),(17,1),(9,1),(4,1),(6,1),(15,1),(17,1);
explain
SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
2 SUBQUERY t3 ALL NULL NULL NULL NULL 13 Using where
2 SUBQUERY t2 ref b b 4 test.t3.a 1 Using index
SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a);
a
19
19
19
20
20
20
20
20
20
DROP TABLE t1,t2,t3;
set optimizer_switch=@tmp_877288;
set optimizer_switch=@subselect_sj_tmp;

View File

@ -1974,6 +1974,37 @@ ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your W
set max_join_size= @tmp_mjs_861147;
set optimizer_switch= @tmp_os_861147;
DROP TABLE t1,t2,t3,t4,t5,t6;
#
# BUG#877288: Wrong result with semijoin + materialization + multipart key
#
set @tmp_877288=@@optimizer_switch;
set optimizer_switch='semijoin=ON,materialization=ON';
CREATE TABLE t1 ( a int) ;
INSERT INTO t1 VALUES (19),(19),(19),(20),(20),(20),(20),(20),(20);
CREATE TABLE t2 ( b int NOT NULL , c int NOT NULL , KEY (b,c)) ;
INSERT INTO t2 VALUES (14,1),(15,1),(16,1),(17,1),(18,1),(19,1),(20,1);
CREATE TABLE t3 ( a int, d int) ;
INSERT INTO t3 VALUES (19,1),(7,1),(3,1),(3,1),(20,1),(3,1),(16,1),(17,1),(9,1),(4,1),(6,1),(15,1),(17,1);
explain
SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
2 SUBQUERY t3 ALL NULL NULL NULL NULL 13 Using where
2 SUBQUERY t2 ref b b 4 test.t3.a 1 Using index
SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a);
a
19
19
19
20
20
20
20
20
20
DROP TABLE t1,t2,t3;
set optimizer_switch=@tmp_877288;
set optimizer_switch=@subselect_sj_tmp;
#
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off

View File

@ -1807,6 +1807,25 @@ set optimizer_switch= @tmp_os_861147;
DROP TABLE t1,t2,t3,t4,t5,t6;
--echo #
--echo # BUG#877288: Wrong result with semijoin + materialization + multipart key
--echo #
set @tmp_877288=@@optimizer_switch;
set optimizer_switch='semijoin=ON,materialization=ON';
CREATE TABLE t1 ( a int) ;
INSERT INTO t1 VALUES (19),(19),(19),(20),(20),(20),(20),(20),(20);
CREATE TABLE t2 ( b int NOT NULL , c int NOT NULL , KEY (b,c)) ;
INSERT INTO t2 VALUES (14,1),(15,1),(16,1),(17,1),(18,1),(19,1),(20,1);
CREATE TABLE t3 ( a int, d int) ;
INSERT INTO t3 VALUES (19,1),(7,1),(3,1),(3,1),(20,1),(3,1),(16,1),(17,1),(9,1),(4,1),(6,1),(15,1),(17,1);
explain
SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a);
SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a);
DROP TABLE t1,t2,t3;
set optimizer_switch=@tmp_877288;
# The following command must be the last one the file
set optimizer_switch=@subselect_sj_tmp;