mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
Merge fix for BUG#784723
This commit is contained in:
commit
23cfe1261d
6 changed files with 81 additions and 6 deletions
|
@ -1218,4 +1218,31 @@ IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key)
|
|||
AND pk = 9;
|
||||
datetime_key
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# BUG#784723: Wrong result with semijoin + nested subqueries in maria-5.3
|
||||
#
|
||||
CREATE TABLE t1 ( t1field integer, primary key (t1field));
|
||||
CREATE TABLE t2 ( t2field integer, primary key (t2field));
|
||||
INSERT INTO t1 VALUES (1),(2),(3);
|
||||
INSERT INTO t2 VALUES (2),(3),(4);
|
||||
explain
|
||||
SELECT * FROM t1 A
|
||||
WHERE
|
||||
A.t1field IN (SELECT A.t1field FROM t2 B) AND
|
||||
A.t1field IN (SELECT C.t2field FROM t2 C
|
||||
WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY A index PRIMARY PRIMARY 4 NULL 3 Using index; Start temporary
|
||||
1 PRIMARY B index NULL PRIMARY 4 NULL 3 Using index; End temporary; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY C eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index
|
||||
1 PRIMARY D eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index
|
||||
SELECT * FROM t1 A
|
||||
WHERE
|
||||
A.t1field IN (SELECT A.t1field FROM t2 B) AND
|
||||
A.t1field IN (SELECT C.t2field FROM t2 C
|
||||
WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
|
||||
t1field
|
||||
2
|
||||
3
|
||||
drop table t1,t2;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
|
|
@ -303,9 +303,10 @@ t2.Code IN (SELECT Country FROM t3
|
|||
WHERE Language='English' AND Percentage > 10 AND
|
||||
t2.Population > 100000);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 1
|
||||
1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where
|
||||
1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where
|
||||
2 SUBQUERY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
DROP TABLE t1,t2,t3;
|
||||
CREATE TABLE t1 (
|
||||
Code char(3) NOT NULL DEFAULT '',
|
||||
|
|
|
@ -310,9 +310,10 @@ t2.Code IN (SELECT Country FROM t3
|
|||
WHERE Language='English' AND Percentage > 10 AND
|
||||
t2.Population > 100000);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 1
|
||||
1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
|
||||
1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
|
||||
2 SUBQUERY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
DROP TABLE t1,t2,t3;
|
||||
CREATE TABLE t1 (
|
||||
Code char(3) NOT NULL DEFAULT '',
|
||||
|
|
|
@ -1226,6 +1226,33 @@ IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key)
|
|||
AND pk = 9;
|
||||
datetime_key
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# BUG#784723: Wrong result with semijoin + nested subqueries in maria-5.3
|
||||
#
|
||||
CREATE TABLE t1 ( t1field integer, primary key (t1field));
|
||||
CREATE TABLE t2 ( t2field integer, primary key (t2field));
|
||||
INSERT INTO t1 VALUES (1),(2),(3);
|
||||
INSERT INTO t2 VALUES (2),(3),(4);
|
||||
explain
|
||||
SELECT * FROM t1 A
|
||||
WHERE
|
||||
A.t1field IN (SELECT A.t1field FROM t2 B) AND
|
||||
A.t1field IN (SELECT C.t2field FROM t2 C
|
||||
WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY A index PRIMARY PRIMARY 4 NULL 3 Using index; Start temporary
|
||||
1 PRIMARY B index NULL PRIMARY 4 NULL 3 Using index; End temporary; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY C eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index
|
||||
1 PRIMARY D eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index
|
||||
SELECT * FROM t1 A
|
||||
WHERE
|
||||
A.t1field IN (SELECT A.t1field FROM t2 B) AND
|
||||
A.t1field IN (SELECT C.t2field FROM t2 C
|
||||
WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
|
||||
t1field
|
||||
2
|
||||
3
|
||||
drop table t1,t2;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
|
||||
|
|
|
@ -1117,6 +1117,25 @@ WHERE (int_nokey, pk)
|
|||
|
||||
DROP TABLE t1, t2, t3;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#784723: Wrong result with semijoin + nested subqueries in maria-5.3
|
||||
--echo #
|
||||
CREATE TABLE t1 ( t1field integer, primary key (t1field));
|
||||
CREATE TABLE t2 ( t2field integer, primary key (t2field));
|
||||
INSERT INTO t1 VALUES (1),(2),(3);
|
||||
INSERT INTO t2 VALUES (2),(3),(4);
|
||||
explain
|
||||
SELECT * FROM t1 A
|
||||
WHERE
|
||||
A.t1field IN (SELECT A.t1field FROM t2 B) AND
|
||||
A.t1field IN (SELECT C.t2field FROM t2 C
|
||||
WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
|
||||
SELECT * FROM t1 A
|
||||
WHERE
|
||||
A.t1field IN (SELECT A.t1field FROM t2 B) AND
|
||||
A.t1field IN (SELECT C.t2field FROM t2 C
|
||||
WHERE C.t2field IN (SELECT D.t2field FROM t2 D));
|
||||
drop table t1,t2;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
|
|
@ -1551,6 +1551,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
|
|||
pos->prefix_record_count= *current_record_count;
|
||||
pos->sj_strategy= SJ_OPT_NONE;
|
||||
|
||||
pos->prefix_dups_producing_tables= join->cur_dups_producing_tables;
|
||||
/* Initialize the state or copy it from prev. tables */
|
||||
if (idx == join->const_tables)
|
||||
{
|
||||
|
@ -1983,7 +1984,6 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
|
|||
}
|
||||
}
|
||||
}
|
||||
pos->prefix_dups_producing_tables= join->cur_dups_producing_tables;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue