Commit 090b4a10 authored by unknown's avatar unknown

MWL#89

Adjusted test cases in accordance with the implementation.
parent 849f56e8
...@@ -102,6 +102,8 @@ a ...@@ -102,6 +102,8 @@ a
foo foo
Warnings: Warnings:
Error 1259 ZLIB: Input data corrupted Error 1259 ZLIB: Input data corrupted
Error 1259 ZLIB: Input data corrupted
Error 1259 ZLIB: Input data corrupted
explain select *, uncompress(a) from t1; explain select *, uncompress(a) from t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 1 SIMPLE t1 system NULL NULL NULL NULL 1
......
...@@ -1543,8 +1543,7 @@ EXPLAIN SELECT 1 FROM t1 WHERE a IN ...@@ -1543,8 +1543,7 @@ EXPLAIN SELECT 1 FROM t1 WHERE a IN
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index PRIMARY,i2 PRIMARY 4 NULL 144 Using index 1 PRIMARY t1 index PRIMARY,i2 PRIMARY 4 NULL 144 Using index
1 PRIMARY subselect2 eq_ref unique_key unique_key 4 func 1 1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t1)
2 SUBQUERY t1 ALL NULL NULL NULL NULL 144
CREATE TABLE t2 (a INT, b INT, KEY(a)); CREATE TABLE t2 (a INT, b INT, KEY(a));
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4); INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2; EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2;
......
...@@ -2402,7 +2402,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE ...@@ -2402,7 +2402,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using where; Using index 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using where; Using index
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by 2 DEPENDENT SUBQUERY t1 index NULL a 10 NULL 1 Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
......
...@@ -1484,7 +1484,7 @@ EXPLAIN SELECT t1.f1 FROM t1 ...@@ -1484,7 +1484,7 @@ EXPLAIN SELECT t1.f1 FROM t1
WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2; WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
2 DEPENDENT SUBQUERY t2 ref f2,f3 f2 5 1 Using where 2 DEPENDENT SUBQUERY t2 ref f2,f3 f2 5 const 1 Using where
DROP TABLE t1,t2; DROP TABLE t1,t2;
create table t0 (a int); create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
......
...@@ -598,7 +598,7 @@ VALUES ...@@ -598,7 +598,7 @@ VALUES
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by 2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
SELECT 1 as RES FROM t1 AS t1_outer WHERE SELECT 1 as RES FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
......
...@@ -347,10 +347,10 @@ WHERE t2.int_key IS NULL ...@@ -347,10 +347,10 @@ WHERE t2.int_key IS NULL
GROUP BY t2.pk GROUP BY t2.pk
); );
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
2 SUBQUERY t2 ref int_key int_key 5 1 100.00 Using index condition; Using where; Using filesort 2 SUBQUERY t2 ref int_key int_key 5 const 1 100.00 Using index condition; Using where; Using filesort
Warnings: Warnings:
Note 1003 select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where 0 Note 1003 select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where exists(select `test`.`t2`.`pk` from `test`.`t2` where isnull(`test`.`t2`.`int_key`) group by `test`.`t2`.`pk`)
DROP TABLE t1, t2; DROP TABLE t1, t2;
# #
# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation # BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation
......
This diff is collapsed.
...@@ -120,9 +120,9 @@ create table t1 (a int primary key); ...@@ -120,9 +120,9 @@ create table t1 (a int primary key);
insert into t1 values (1); insert into t1 values (1);
explain select * from t1 where 3 in (select (1+1) union select 1); explain select * from t1 where 3 in (select (1+1) union select 1);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible HAVING 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL Impossible HAVING 3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
select * from t1 where 3 in (select (1+1) union select 1); select * from t1 where 3 in (select (1+1) union select 1);
a a
......
...@@ -1105,8 +1105,6 @@ count(*) ...@@ -1105,8 +1105,6 @@ count(*)
7 7
Warnings: Warnings:
Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
drop table t1; drop table t1;
create table t1 (col1 char(3), col2 integer); create table t1 (col1 char(3), col2 integer);
insert into t1 (col1) values (cast(1000 as char(3))); insert into t1 (col1) values (cast(1000 as char(3)));
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -15,7 +15,7 @@ ORDER BY count(*); ...@@ -15,7 +15,7 @@ ORDER BY count(*);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 2 Using where; Using index; Using temporary 1 PRIMARY t1 index NULL a 5 NULL 2 Using where; Using index; Using temporary
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 0 const row not found 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
# should not crash the next statement # should not crash the next statement
SELECT 1 FROM t1 SELECT 1 FROM t1
WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3)) WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3))
...@@ -117,14 +117,14 @@ EXPLAIN ...@@ -117,14 +117,14 @@ EXPLAIN
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ); SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 );
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
x PRIMARY x x x x x x x x x PRIMARY x x x x x x x x
x SUBQUERY x x x x x x x x x DEPENDENT SUBQUERY x x x x x x x x
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ); SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 );
a b a b
EXPLAIN EXPLAIN
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL; SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL; SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT c, d FROM t2 ) IS NULL;
a b a b
1 NULL 1 NULL
...@@ -147,28 +147,28 @@ EXPLAIN ...@@ -147,28 +147,28 @@ EXPLAIN
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 ); SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 );
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
x PRIMARY x x x x x x x x x PRIMARY x x x x x x x x
x SUBQUERY x x x x x x x x x DEPENDENT SUBQUERY x x x x x x x x
SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 ); SELECT * FROM t1 WHERE ( a, b ) NOT IN ( SELECT e, f FROM t3 );
a b a b
EXPLAIN EXPLAIN
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 ); SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 );
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
x PRIMARY x x x x x x x x x PRIMARY x x x x x x x x
x SUBQUERY x x x x x x x x x DEPENDENT SUBQUERY x x x x x x x x
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 ); SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT a, b FROM t1 );
c d c d
EXPLAIN EXPLAIN
SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 ); SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 );
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
x PRIMARY x x x x x x x x x PRIMARY x x x x x x x x
x SUBQUERY x x x x x x x x x DEPENDENT SUBQUERY x x x x x x x x
SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 ); SELECT * FROM t3 WHERE ( e, f ) NOT IN ( SELECT c, d FROM t2 );
e f e f
EXPLAIN EXPLAIN
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 ); SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 );
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
x PRIMARY x x x x x x x x x PRIMARY x x x x x x x x
x SUBQUERY x x x x x x x x x DEPENDENT SUBQUERY x x x x x x x x
SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 ); SELECT * FROM t2 WHERE ( c, d ) NOT IN ( SELECT e, f FROM t3 );
c d c d
SELECT * FROM t1 WHERE ( a, b ) NOT IN SELECT * FROM t1 WHERE ( a, b ) NOT IN
...@@ -496,28 +496,33 @@ INSERT INTO t4 VALUES ('k'), ('d'); ...@@ -496,28 +496,33 @@ INSERT INTO t4 VALUES ('k'), ('d');
EXPLAIN EXPLAIN
SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2); SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2); SELECT * FROM t1 RIGHT JOIN t2 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
c1 c1 c1 c1
EXPLAIN EXPLAIN
SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2); SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2); SELECT * FROM t2 LEFT JOIN t1 ON t1.c1 WHERE 's' IN (SELECT c1 FROM t2);
c1 c1 c1 c1
EXPLAIN EXPLAIN
SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2); SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2); SELECT * FROM (t2 LEFT JOIN t1 ON t1.c1) LEFT JOIN t3 on t3.c1 WHERE 's' IN (SELECT c1 FROM t2);
c1 c1 c1 c1 c1 c1
EXPLAIN EXPLAIN
SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2); SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY t4 index NULL PRIMARY 3 NULL 2 Using index
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2); SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
c1 c1 c1 c1
...@@ -539,7 +544,7 @@ WHERE f1 IN (SELECT t1.f2 FROM t1 JOIN t3 ON t3.f4); ...@@ -539,7 +544,7 @@ WHERE f1 IN (SELECT t1.f2 FROM t1 JOIN t3 ON t3.f4);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY t2 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer 2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
drop table t1, t2, t3; drop table t1, t2, t3;
# #
# LP BUG#680005 Second assertion `cache != __null' failed in # LP BUG#680005 Second assertion `cache != __null' failed in
...@@ -568,10 +573,10 @@ ON SUBQUERY2_t3.f2) ...@@ -568,10 +573,10 @@ ON SUBQUERY2_t3.f2)
GROUP BY t1.f4 ORDER BY t1.f1 LIMIT 10; GROUP BY t1.f4 ORDER BY t1.f1 LIMIT 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 Using temporary; Using filesort 1 PRIMARY t2 system NULL NULL NULL NULL 1 Using temporary; Using filesort
1 PRIMARY t1 index NULL f4 5 NULL 10 Using where 1 PRIMARY t1 index NULL f4 5 NULL 11 Using where
2 DEPENDENT SUBQUERY SUBQUERY2_t1 system NULL NULL NULL NULL 1 2 DEPENDENT SUBQUERY SUBQUERY2_t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY SUBQUERY2_t2 index NULL f4 5 NULL 11 Using where; Using index 2 DEPENDENT SUBQUERY SUBQUERY2_t2 index NULL f4 5 NULL 11 Using index
2 DEPENDENT SUBQUERY SUBQUERY2_t3 ALL NULL NULL NULL NULL 11 Using where; Using join buffer 2 DEPENDENT SUBQUERY SUBQUERY2_t3 ALL NULL NULL NULL NULL 11 Using where; Using join buffer (flat, BNL join)
drop table t1, t2, t3; drop table t1, t2, t3;
# #
# LP BUG#680038 bool close_thread_table(THD*, TABLE**): # LP BUG#680038 bool close_thread_table(THD*, TABLE**):
...@@ -595,7 +600,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -595,7 +600,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary; Using filesort 3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary; Using filesort
3 SUBQUERY SQ1_t3 index NULL f4 5 NULL 2 Using where; Using index; Using join buffer 3 SUBQUERY SQ1_t3 index NULL f4 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
drop table t1, t2, t3; drop table t1, t2, t3;
# #
# BUG#52317: Assertion failing in Field_varstring::store() # BUG#52317: Assertion failing in Field_varstring::store()
...@@ -608,7 +613,7 @@ INSERT INTO t2 VALUES (1), (2); ...@@ -608,7 +613,7 @@ INSERT INTO t2 VALUES (1), (2);
EXPLAIN EXPLAIN
SELECT i FROM t1 WHERE (1) NOT IN (SELECT i FROM t2); SELECT i FROM t1 WHERE (1) NOT IN (SELECT i FROM t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t2 index_subquery k k 5 const 2 Using index 2 DEPENDENT SUBQUERY t2 index_subquery k k 5 const 2 Using index
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t1; DROP TABLE t1;
...@@ -626,7 +631,7 @@ FROM t2 JOIN t1 ON t1.f3 ...@@ -626,7 +631,7 @@ FROM t2 JOIN t1 ON t1.f3
WHERE ('v') IN (SELECT f4 FROM t2) WHERE ('v') IN (SELECT f4 FROM t2)
GROUP BY f9; GROUP BY f9;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 Using temporary; Using filesort 1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
...@@ -661,8 +666,8 @@ FROM t2 JOIN t1 ...@@ -661,8 +666,8 @@ FROM t2 JOIN t1
WHERE ('v') IN (SELECT f4 FROM t2) WHERE ('v') IN (SELECT f4 FROM t2)
GROUP BY f9; GROUP BY f9;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 Using temporary; Using filesort 1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
SELECT COUNT(t2.f3), SELECT COUNT(t2.f3),
...@@ -679,7 +684,7 @@ WHERE ('v') IN (SELECT f4 FROM t2) ...@@ -679,7 +684,7 @@ WHERE ('v') IN (SELECT f4 FROM t2)
ORDER BY f9; ORDER BY f9;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
SELECT COUNT(t2.f3), SELECT COUNT(t2.f3),
......
...@@ -456,8 +456,8 @@ Handler_read_first 0 ...@@ -456,8 +456,8 @@ Handler_read_first 0
Handler_read_key 7 Handler_read_key 7
Handler_read_next 0 Handler_read_next 0
Handler_read_prev 0 Handler_read_prev 0
Handler_read_rnd 0 Handler_read_rnd 10
Handler_read_rnd_next 31 Handler_read_rnd_next 42
set optimizer_switch='subquery_cache=off'; set optimizer_switch='subquery_cache=off';
flush status; flush status;
select a from t1 ORDER BY (select d from t2 where b=c); select a from t1 ORDER BY (select d from t2 where b=c);
...@@ -482,8 +482,8 @@ Handler_read_first 0 ...@@ -482,8 +482,8 @@ Handler_read_first 0
Handler_read_key 0 Handler_read_key 0
Handler_read_next 0 Handler_read_next 0
Handler_read_prev 0 Handler_read_prev 0
Handler_read_rnd 0 Handler_read_rnd 10
Handler_read_rnd_next 61 Handler_read_rnd_next 72
set optimizer_switch='subquery_cache=on'; set optimizer_switch='subquery_cache=on';
#single value subquery test (distinct ORDER BY) #single value subquery test (distinct ORDER BY)
flush status; flush status;
...@@ -897,7 +897,7 @@ a b SUBS ...@@ -897,7 +897,7 @@ a b SUBS
5 6 1 5 6 1
4 5 1 4 5 1
7 8 NULL 7 8 NULL
9 NULL 1 9 NULL NULL
show status like "subquery_cache%"; show status like "subquery_cache%";
Variable_name Value Variable_name Value
Subquery_cache_hit 0 Subquery_cache_hit 0
...@@ -916,7 +916,7 @@ a b SUBS ...@@ -916,7 +916,7 @@ a b SUBS
5 6 1 5 6 1
4 5 1 4 5 1
7 8 NULL 7 8 NULL
9 NULL 1 9 NULL NULL
show status like "subquery_cache%"; show status like "subquery_cache%";
Variable_name Value Variable_name Value
Subquery_cache_hit 6 Subquery_cache_hit 6
...@@ -977,7 +977,7 @@ a b SUBS ...@@ -977,7 +977,7 @@ a b SUBS
5 6 0 5 6 0
4 5 0 4 5 0
7 8 NULL 7 8 NULL
9 NULL 0 9 NULL NULL
show status like "subquery_cache%"; show status like "subquery_cache%";
Variable_name Value Variable_name Value
Subquery_cache_hit 0 Subquery_cache_hit 0
...@@ -996,7 +996,7 @@ a b SUBS ...@@ -996,7 +996,7 @@ a b SUBS
5 6 0 5 6 0
4 5 0 4 5 0
7 8 NULL 7 8 NULL
9 NULL 0 9 NULL NULL
show status like "subquery_cache%"; show status like "subquery_cache%";
Variable_name Value Variable_name Value
Subquery_cache_hit 6 Subquery_cache_hit 6
...@@ -1336,11 +1336,11 @@ Subquery_cache_miss 0 ...@@ -1336,11 +1336,11 @@ Subquery_cache_miss 0
show status like '%Handler_read%'; show status like '%Handler_read%';
Variable_name Value Variable_name Value
Handler_read_first 0 Handler_read_first 0
Handler_read_key 11 Handler_read_key 0
Handler_read_next 0 Handler_read_next 0
Handler_read_prev 0 Handler_read_prev 0
Handler_read_rnd 0 Handler_read_rnd 0
Handler_read_rnd_next 145 Handler_read_rnd_next 188
set optimizer_switch='subquery_cache=on'; set optimizer_switch='subquery_cache=on';
flush status; flush status;
select a, b , exists (select * from t2 where b=d) as SUBSE, b in (select d from t2) as SUBSI, (select d from t2 where b=c) SUBSR from t1; select a, b , exists (select * from t2 where b=d) as SUBSE, b in (select d from t2) as SUBSI, (select d from t2 where b=c) SUBSR from t1;
...@@ -1364,11 +1364,11 @@ Subquery_cache_miss 18 ...@@ -1364,11 +1364,11 @@ Subquery_cache_miss 18
show status like '%Handler_read%'; show status like '%Handler_read%';
Variable_name Value Variable_name Value
Handler_read_first 0 Handler_read_first 0
Handler_read_key 32 Handler_read_key 27
Handler_read_next 0 Handler_read_next 0
Handler_read_prev 0 Handler_read_prev 0
Handler_read_rnd 0 Handler_read_rnd 0
Handler_read_rnd_next 84 Handler_read_rnd_next 102
#several subqueries (several levels) #several subqueries (several levels)
set optimizer_switch='subquery_cache=off'; set optimizer_switch='subquery_cache=off';
flush status; flush status;
...@@ -3195,7 +3195,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -3195,7 +3195,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` where (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`b`)))) Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`b` from `test`.`t2` where (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`b`))))
drop table t1,t2; drop table t1,t2;
set @@optimizer_switch= default; set @@optimizer_switch= default;
# LP BUG#615760 (part 2: incorrect heap table index flags) # LP BUG#615760 (part 2: incorrect heap table index flags)
......
This diff is collapsed.
select @@optimizer_switch like '%materialization=on%'; select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%' @@optimizer_switch like '%materialization=on%'
1 0
set optimizer_switch='materialization=off'; set optimizer_switch='materialization=off';
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12;
drop view if exists v2; drop view if exists v2;
...@@ -427,7 +427,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -427,7 +427,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used 3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings: Warnings:
Note 1003 select 1 AS `1` from `test`.`t1` where 1 Note 1003 select 1 AS `1` from `test`.`t1` where (1 = (select 1 union select 1))
drop table t1; drop table t1;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`numeropost` mediumint(8) unsigned NOT NULL auto_increment, `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
...@@ -913,7 +913,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -913,7 +913,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using index 2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using index
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
drop table t1,t2,t3; drop table t1,t2,t3;
create table t1 (a float); create table t1 (a float);
select 10.5 IN (SELECT * from t1 LIMIT 1); select 10.5 IN (SELECT * from t1 LIMIT 1);
...@@ -1184,9 +1184,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a); ...@@ -1184,9 +1184,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1'); INSERT INTO t1 (pseudo) VALUES ('test1');
SELECT 0 IN (SELECT 1 FROM t1 a); SELECT 0 IN (SELECT 1 FROM t1 a);
0 IN (SELECT 1 FROM t1 a) 0 IN (SELECT 1 FROM t1 a)
...@@ -1194,9 +1194,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a); ...@@ -1194,9 +1194,9 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (<cache>(0) = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1; drop table t1;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`i` int(11) NOT NULL default '0', `i` int(11) NOT NULL default '0',
...@@ -1539,34 +1539,34 @@ select * from t3 where NULL >= any (select b from t2); ...@@ -1539,34 +1539,34 @@ select * from t3 where NULL >= any (select b from t2);
a a
explain extended select * from t3 where NULL >= any (select b from t2); explain extended select * from t3 where NULL >= any (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0 Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(NULL) from `test`.`t2`)))
select * from t3 where NULL >= any (select b from t2 group by 1); select * from t3 where NULL >= any (select b from t2 group by 1);
a a
explain extended select * from t3 where NULL >= any (select b from t2 group by 1); explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0 Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select NULL from `test`.`t2` group by 1)))
select * from t3 where NULL >= some (select b from t2); select * from t3 where NULL >= some (select b from t2);
a a
explain extended select * from t3 where NULL >= some (select b from t2); explain extended select * from t3 where NULL >= some (select b from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0 Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= (select min(NULL) from `test`.`t2`)))
select * from t3 where NULL >= some (select b from t2 group by 1); select * from t3 where NULL >= some (select b from t2 group by 1);
a a
explain extended select * from t3 where NULL >= some (select b from t2 group by 1); explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
Warnings: Warnings:
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0 Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>((NULL >= <min>(select NULL from `test`.`t2` group by 1)))
insert into t2 values (2,2), (2,1), (3,3), (3,1); insert into t2 values (2,2), (2,1), (3,3), (3,1);
select * from t3 where a > all (select max(b) from t2 group by a); select * from t3 where a > all (select max(b) from t2 group by a);
a a
...@@ -1628,7 +1628,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1628,7 +1628,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 UNION t1 system NULL NULL NULL NULL 1 100.00 3 UNION t1 system NULL NULL NULL NULL 1 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings: Warnings:
Note 1003 select 'e' AS `s1` from `test`.`t1` where 1 Note 1003 select 'e' AS `s1` from `test`.`t1` where <nop>(('f' > <min>(select 'e' from `test`.`t1` union select 'e' from `test`.`t1`)))
drop table t1; drop table t1;
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1; CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874'); INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
...@@ -3113,10 +3113,10 @@ SELECT a FROM t1 ...@@ -3113,10 +3113,10 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2), ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)); (SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a a
2
4
1 1
2
3 3
4
SELECT a FROM t1 SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1), ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b)); (SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
...@@ -3125,8 +3125,8 @@ SELECT a FROM t1 ...@@ -3125,8 +3125,8 @@ SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4), ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)); (SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a a
2
1 1
2
3 3
4 4
SELECT a FROM t1 SELECT a FROM t1
...@@ -3434,7 +3434,7 @@ EXPLAIN ...@@ -3434,7 +3434,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a); SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1 Using filesort 2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1
DROP TABLE t1; DROP TABLE t1;
create table t1( f1 int,f2 int); create table t1( f1 int,f2 int);
insert into t1 values (1,1),(2,2); insert into t1 values (1,1),(2,2);
...@@ -4326,13 +4326,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -4326,13 +4326,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
Warnings: Warnings:
Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having 1))) Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1)))))
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a); EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
Warnings: Warnings:
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having 1)) Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1)))))
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#45061: Incorrectly market field caused wrong result. # Bug#45061: Incorrectly market field caused wrong result.
...@@ -4977,4 +4977,4 @@ drop view v2; ...@@ -4977,4 +4977,4 @@ drop view v2;
set optimizer_switch=default; set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%'; select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%' @@optimizer_switch like '%materialization=on%'
1 0
This diff is collapsed.
This diff is collapsed.
...@@ -406,24 +406,6 @@ SELECT t1 .varchar_key from t1 ...@@ -406,24 +406,6 @@ SELECT t1 .varchar_key from t1
int_key int_key
9 9
7 7
SELECT t0.int_key
FROM t0
WHERE t0.varchar_nokey IN (
SELECT t1_1 .varchar_key
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
);
int_key
9
7
SELECT t0.int_key
FROM t0, t2
WHERE t0.varchar_nokey IN (
SELECT t1_1 .varchar_key
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
);
int_key
9
7
DROP TABLE t0, t1, t2; DROP TABLE t0, t1, t2;
# End of bug#46550 # End of bug#46550
# #
...@@ -774,11 +756,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -774,11 +756,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings: Warnings:
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))))) Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
show warnings; show warnings;
Level Code Message Level Code Message
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))))) Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
select a from t1 select a from t1
where a in (select c from t2 where d >= some(select e from t3 where b=e)); where a in (select c from t2 where d >= some(select e from t3 where b=e));
a a
...@@ -811,10 +793,9 @@ INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','f ...@@ -811,10 +793,9 @@ INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','f
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY subselect2 eq_ref unique_key unique_key 13 func 1 1.00 1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1)
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using MRR
Warnings: Warnings:
Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`pk` > 0)) Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0))
SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
pk pk
2 2
...@@ -980,10 +961,9 @@ FROM t1 ...@@ -980,10 +961,9 @@ FROM t1
WHERE `varchar_nokey` < 'n' XOR `pk` ) ; WHERE `varchar_nokey` < 'n' XOR `pk` ) ;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00
1 PRIMARY subselect2 eq_ref unique_key unique_key 8 func 1 1.00 1 PRIMARY t1 ref varchar_key varchar_key 3 test.t2.varchar_nokey 2 105.00 Using where; FirstMatch(t2)
2 SUBQUERY t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key`) and ((`test`.`t1`.`varchar_nokey` < 'n') xor `test`.`t1`.`pk`)) Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_key` = `test`.`t2`.`varchar_nokey`) and (`test`.`t1`.`varchar_nokey` = `test`.`t2`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor `test`.`t1`.`pk`))
SELECT varchar_nokey SELECT varchar_nokey
FROM t2 FROM t2
WHERE ( `varchar_nokey` , `varchar_nokey` ) IN ( WHERE ( `varchar_nokey` , `varchar_nokey` ) IN (
...@@ -1061,11 +1041,9 @@ WHERE t2.val LIKE 'a%' OR t2.val LIKE 'e%') ...@@ -1061,11 +1041,9 @@ WHERE t2.val LIKE 'a%' OR t2.val LIKE 'e%')
AND t1.val IN (SELECT t3.val FROM t3 AND t1.val IN (SELECT t3.val FROM t3
WHERE t3.val LIKE 'a%' OR t3.val LIKE 'e%'); WHERE t3.val LIKE 'a%' OR t3.val LIKE 'e%');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Start temporary
1 PRIMARY subselect3 eq_ref unique_key unique_key 14 func 1 1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
1 PRIMARY subselect2 eq_ref unique_key unique_key 14 func 1 1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (flat, BNL join)
3 SUBQUERY t3 ALL NULL NULL NULL NULL 5 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
SELECT * SELECT *
FROM t1 FROM t1
WHERE t1.val IN (SELECT t2.val FROM t2 WHERE t1.val IN (SELECT t2.val FROM t2
......
...@@ -32,9 +32,8 @@ a b ...@@ -32,9 +32,8 @@ a b
9 5 9 5
explain select * from t2 where b in (select a from t1); explain select * from t2 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 3 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
1 PRIMARY t2 ref b b 5 test.t1.a 2 1 PRIMARY t2 ref b b 5 test.t1.a 2 End temporary
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
select * from t2 where b in (select a from t1); select * from t2 where b in (select a from t1);
a b a b
1 1 1 1
...@@ -51,9 +50,8 @@ primary key(pk1, pk2, pk3) ...@@ -51,9 +50,8 @@ primary key(pk1, pk2, pk3)
insert into t3 select a,a, a,a,a from t0; insert into t3 select a,a, a,a,a from t0;
explain select * from t3 where b in (select a from t1); explain select * from t3 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 ALL b NULL NULL NULL 10 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY t3 ref b b 5 test.t1.a 1 End temporary
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
select * from t3 where b in (select a from t1); select * from t3 where b in (select a from t1);
a b pk1 pk2 pk3 a b pk1 pk2 pk3
1 1 1 1 1 1 1 1 1 1
...@@ -75,9 +73,8 @@ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a ...@@ -75,9 +73,8 @@ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a
from t0 A, t0 B where B.a <5; from t0 A, t0 B where B.a <5;
explain select * from t3 where b in (select a from t0); explain select * from t3 where b in (select a from t0);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10 1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where; Start temporary
1 PRIMARY t3 ref b b 5 test.t0.a 1 1 PRIMARY t3 ref b b 5 test.t0.a 1 End temporary
2 SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
set @save_ecp= @@engine_condition_pushdown; set @save_ecp= @@engine_condition_pushdown;
set engine_condition_pushdown=0; set engine_condition_pushdown=0;
select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5); select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
...@@ -101,9 +98,8 @@ set join_buffer_size= @save_join_buffer_size; ...@@ -101,9 +98,8 @@ set join_buffer_size= @save_join_buffer_size;
set max_heap_table_size= @save_max_heap_table_size; set max_heap_table_size= @save_max_heap_table_size;
explain select * from t1 where a in (select b from t2); explain select * from t1 where a in (select b from t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY t2 ref b b 5 test.t1.a 2 Using index; FirstMatch(t1)
2 SUBQUERY t2 index b b 5 NULL 10 Using index
select * from t1; select * from t1;
a b a b
1 1 1 1
...@@ -130,9 +126,8 @@ explain select ...@@ -130,9 +126,8 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22 1 PRIMARY it ALL NULL NULL NULL NULL 22 Start temporary
1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer (flat, BNL join) 1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; End temporary; Using join buffer (flat, BNL join)
2 SUBQUERY it ALL NULL NULL NULL NULL 22
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
...@@ -164,8 +159,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) ...@@ -164,8 +159,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22 1 PRIMARY ot ALL NULL NULL NULL NULL 22
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY it ALL NULL NULL NULL NULL 32 Using where; FirstMatch(ot)
2 SUBQUERY it ALL NULL NULL NULL NULL 32
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
...@@ -198,9 +192,8 @@ explain select ...@@ -198,9 +192,8 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22 1 PRIMARY it ALL NULL NULL NULL NULL 22 Start temporary
1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer (flat, BNL join) 1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; End temporary; Using join buffer (flat, BNL join)
2 SUBQUERY it ALL NULL NULL NULL NULL 22
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
...@@ -232,8 +225,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) ...@@ -232,8 +225,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22 1 PRIMARY ot ALL NULL NULL NULL NULL 22
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY it ALL NULL NULL NULL NULL 52 Using where; FirstMatch(ot)
2 SUBQUERY it ALL NULL NULL NULL NULL 52
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
...@@ -349,8 +341,7 @@ WHERE t1.Code IN ( ...@@ -349,8 +341,7 @@ WHERE t1.Code IN (
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31 1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31
1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1 1 PRIMARY t2 ref CountryCode CountryCode 3 test.t1.Code 18 Using where; FirstMatch(t1)
2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where
SELECT Name FROM t1 SELECT Name FROM t1
WHERE t1.Code IN ( WHERE t1.Code IN (
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
...@@ -692,9 +683,8 @@ alter table t3 add primary key(id), add key(a); ...@@ -692,9 +683,8 @@ alter table t3 add primary key(id), add key(a);
The following must use loose index scan over t3, key a: The following must use loose index scan over t3, key a:
explain select count(a) from t2 where a in ( SELECT a FROM t3); explain select count(a) from t2 where a in ( SELECT a FROM t3);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index a a 5 NULL 1000 Using index 1 PRIMARY t2 index a a 5 NULL 1000 Using where; Using index
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY t3 ref a a 5 test.t2.a 30 Using index; FirstMatch(t2)
2 SUBQUERY t3 index a a 5 NULL 30000 Using index
select count(a) from t2 where a in ( SELECT a FROM t3); select count(a) from t2 where a in ( SELECT a FROM t3);
count(a) count(a)
1000 1000
......
...@@ -39,9 +39,8 @@ a b ...@@ -39,9 +39,8 @@ a b
9 5 9 5
explain select * from t2 where b in (select a from t1); explain select * from t2 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 3 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
1 PRIMARY t2 ref b b 5 test.t1.a 2 Using join buffer (flat, BKA join) 1 PRIMARY t2 ref b b 5 test.t1.a 2 End temporary; Using join buffer (flat, BKA join)
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
select * from t2 where b in (select a from t1); select * from t2 where b in (select a from t1);
a b a b
1 1 1 1
...@@ -58,9 +57,8 @@ primary key(pk1, pk2, pk3) ...@@ -58,9 +57,8 @@ primary key(pk1, pk2, pk3)
insert into t3 select a,a, a,a,a from t0; insert into t3 select a,a, a,a,a from t0;
explain select * from t3 where b in (select a from t1); explain select * from t3 where b in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 ALL b NULL NULL NULL 10 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY t3 ref b b 5 test.t1.a 1 End temporary; Using join buffer (flat, BKA join)
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
select * from t3 where b in (select a from t1); select * from t3 where b in (select a from t1);
a b pk1 pk2 pk3 a b pk1 pk2 pk3
1 1 1 1 1 1 1 1 1 1
...@@ -82,9 +80,8 @@ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a ...@@ -82,9 +80,8 @@ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a
from t0 A, t0 B where B.a <5; from t0 A, t0 B where B.a <5;
explain select * from t3 where b in (select a from t0); explain select * from t3 where b in (select a from t0);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 10 1 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where; Start temporary
1 PRIMARY t3 ref b b 5 test.t0.a 1 Using join buffer (flat, BKA join) 1 PRIMARY t3 ref b b 5 test.t0.a 1 End temporary; Using join buffer (flat, BKA join)
2 SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
set @save_ecp= @@engine_condition_pushdown; set @save_ecp= @@engine_condition_pushdown;
set engine_condition_pushdown=0; set engine_condition_pushdown=0;
select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5); select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
...@@ -108,9 +105,8 @@ set join_buffer_size= @save_join_buffer_size; ...@@ -108,9 +105,8 @@ set join_buffer_size= @save_join_buffer_size;
set max_heap_table_size= @save_max_heap_table_size; set max_heap_table_size= @save_max_heap_table_size;
explain select * from t1 where a in (select b from t2); explain select * from t1 where a in (select b from t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY t2 ref b b 5 test.t1.a 2 Using index; FirstMatch(t1)
2 SUBQUERY t2 index b b 5 NULL 10 Using index
select * from t1; select * from t1;
a b a b
1 1 1 1
...@@ -137,9 +133,8 @@ explain select ...@@ -137,9 +133,8 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22 1 PRIMARY it ALL NULL NULL NULL NULL 22 Start temporary
1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer (flat, BNL join) 1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; End temporary; Using join buffer (flat, BNL join)
2 SUBQUERY it ALL NULL NULL NULL NULL 22
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
...@@ -171,8 +166,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) ...@@ -171,8 +166,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22 1 PRIMARY ot ALL NULL NULL NULL NULL 22
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY it ALL NULL NULL NULL NULL 32 Using where; FirstMatch(ot); Using join buffer (flat, BNL join)
2 SUBQUERY it ALL NULL NULL NULL NULL 32
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
...@@ -196,8 +190,8 @@ a mid(filler1, 1,10) length(filler1)=length(filler2) ...@@ -196,8 +190,8 @@ a mid(filler1, 1,10) length(filler1)=length(filler2)
16 filler1234 1 16 filler1234 1
17 filler1234 1 17 filler1234 1
18 filler1234 1 18 filler1234 1
19 filler1234 1
3 duplicate 1 3 duplicate 1
19 filler1234 1
19 duplicate 1 19 duplicate 1
insert into t1 select a+20, 'filler123456', 'filler123456' from t0; insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
insert into t1 select a+20, 'filler123456', 'filler123456' from t0; insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
...@@ -205,9 +199,8 @@ explain select ...@@ -205,9 +199,8 @@ explain select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 22 1 PRIMARY it ALL NULL NULL NULL NULL 22 Start temporary
1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer (flat, BNL join) 1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; End temporary; Using join buffer (flat, BNL join)
2 SUBQUERY it ALL NULL NULL NULL NULL 22
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
from t1 ot where a in (select a from t2 it); from t1 ot where a in (select a from t2 it);
...@@ -239,8 +232,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2) ...@@ -239,8 +232,7 @@ a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY ot ALL NULL NULL NULL NULL 22 1 PRIMARY ot ALL NULL NULL NULL NULL 22
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY it ALL NULL NULL NULL NULL 52 Using where; FirstMatch(ot); Using join buffer (flat, BNL join)
2 SUBQUERY it ALL NULL NULL NULL NULL 52
select select
a, mid(filler1, 1,10), length(filler1)=length(filler2) a, mid(filler1, 1,10), length(filler1)=length(filler2)
from t2 ot where a in (select a from t1 it); from t2 ot where a in (select a from t1 it);
...@@ -264,8 +256,8 @@ a mid(filler1, 1,10) length(filler1)=length(filler2) ...@@ -264,8 +256,8 @@ a mid(filler1, 1,10) length(filler1)=length(filler2)
16 filler1234 1 16 filler1234 1
17 filler1234 1 17 filler1234 1
18 filler1234 1 18 filler1234 1
19 filler1234 1
3 duplicate 1 3 duplicate 1
19 filler1234 1
19 duplicate 1 19 duplicate 1
drop table t1, t2; drop table t1, t2;
create table t1 (a int, b int, key(a)); create table t1 (a int, b int, key(a));
...@@ -356,8 +348,7 @@ WHERE t1.Code IN ( ...@@ -356,8 +348,7 @@ WHERE t1.Code IN (
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31 1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 31
1 PRIMARY subselect2 eq_ref unique_key unique_key 3 func 1 1 PRIMARY t2 ref CountryCode CountryCode 3 test.t1.Code 18 Using where; FirstMatch(t1); Using join buffer (flat, BKA join)
2 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where
SELECT Name FROM t1 SELECT Name FROM t1
WHERE t1.Code IN ( WHERE t1.Code IN (
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
...@@ -701,9 +692,8 @@ alter table t3 add primary key(id), add key(a); ...@@ -701,9 +692,8 @@ alter table t3 add primary key(id), add key(a);
The following must use loose index scan over t3, key a: The following must use loose index scan over t3, key a:
explain select count(a) from t2 where a in ( SELECT a FROM t3); explain select count(a) from t2 where a in ( SELECT a FROM t3);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index a a 5 NULL 1000 Using index 1 PRIMARY t2 index a a 5 NULL 1000 Using where; Using index
1 PRIMARY subselect2 eq_ref unique_key unique_key 5 func 1 1 PRIMARY t3 ref a a 5 test.t2.a 30 Using index; FirstMatch(t2)
2 SUBQUERY t3 index a a 5 NULL 30000 Using index
select count(a) from t2 where a in ( SELECT a FROM t3); select count(a) from t2 where a in ( SELECT a FROM t3);
count(a) count(a)
1000 1000
......
This diff is collapsed.
...@@ -413,24 +413,6 @@ SELECT t1 .varchar_key from t1 ...@@ -413,24 +413,6 @@ SELECT t1 .varchar_key from t1
int_key int_key
9 9
7 7
SELECT t0.int_key
FROM t0
WHERE t0.varchar_nokey IN (
SELECT t1_1 .varchar_key
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
);
int_key
9
7
SELECT t0.int_key
FROM t0, t2
WHERE t0.varchar_nokey IN (
SELECT t1_1 .varchar_key
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
);
int_key
9
7
DROP TABLE t0, t1, t2; DROP TABLE t0, t1, t2;
# End of bug#46550 # End of bug#46550
# #
...@@ -781,11 +763,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -781,11 +763,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings: Warnings:
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))))) Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
show warnings; show warnings;
Level Code Message Level Code Message
Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select 1 from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))))) Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))))
select a from t1 select a from t1
where a in (select c from t2 where d >= some(select e from t3 where b=e)); where a in (select c from t2 where d >= some(select e from t3 where b=e));
a a
...@@ -818,10 +800,9 @@ INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','f ...@@ -818,10 +800,9 @@ INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','f
EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY subselect2 eq_ref unique_key unique_key 13 func 1 1.00 1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (flat, BNL join)
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using MRR
Warnings: Warnings:
Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`pk` > 0)) Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0))
SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0);
pk pk
2 2
...@@ -987,10 +968,9 @@ FROM t1 ...@@ -987,10 +968,9 @@ FROM t1
WHERE `varchar_nokey` < 'n' XOR `pk` ) ; WHERE `varchar_nokey` < 'n' XOR `pk` ) ;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00
1 PRIMARY subselect2 eq_ref unique_key unique_key 8 func 1 1.00 1 PRIMARY t1 ref varchar_key varchar_key 3 test.t2.varchar_nokey 2 105.00 Using where; FirstMatch(t2); Using join buffer (flat, BKA join)
2 SUBQUERY t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key`) and ((`test`.`t1`.`varchar_nokey` < 'n') xor `test`.`t1`.`pk`)) Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`varchar_key` = `test`.`t2`.`varchar_nokey`) and (`test`.`t1`.`varchar_nokey` = `test`.`t2`.`varchar_nokey`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor `test`.`t1`.`pk`))
SELECT varchar_nokey SELECT varchar_nokey
FROM t2 FROM t2
WHERE ( `varchar_nokey` , `varchar_nokey` ) IN ( WHERE ( `varchar_nokey` , `varchar_nokey` ) IN (
...@@ -1068,11 +1048,9 @@ WHERE t2.val LIKE 'a%' OR t2.val LIKE 'e%') ...@@ -1068,11 +1048,9 @@ WHERE t2.val LIKE 'a%' OR t2.val LIKE 'e%')
AND t1.val IN (SELECT t3.val FROM t3 AND t1.val IN (SELECT t3.val FROM t3
WHERE t3.val LIKE 'a%' OR t3.val LIKE 'e%'); WHERE t3.val LIKE 'a%' OR t3.val LIKE 'e%');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Start temporary
1 PRIMARY subselect3 eq_ref unique_key unique_key 14 func 1 1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
1 PRIMARY subselect2 eq_ref unique_key unique_key 14 func 1 1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (incremental, BNL join)
3 SUBQUERY t3 ALL NULL NULL NULL NULL 5 Using where
2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where
SELECT * SELECT *
FROM t1 FROM t1
WHERE t1.val IN (SELECT t2.val FROM t2 WHERE t1.val IN (SELECT t2.val FROM t2
......
...@@ -2078,7 +2078,7 @@ SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 2); ...@@ -2078,7 +2078,7 @@ SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 2);
--error ER_SUBQUERY_NO_1_ROW --error ER_SUBQUERY_NO_1_ROW
SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 1); SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 1);
--sorted_result
SELECT a FROM t1 GROUP BY a SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 2), HAVING IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3; (SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
...@@ -2086,7 +2086,7 @@ SELECT a FROM t1 GROUP BY a ...@@ -2086,7 +2086,7 @@ SELECT a FROM t1 GROUP BY a
SELECT a FROM t1 GROUP BY a SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 1), HAVING IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3; (SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
--sorted_result
SELECT a FROM t1 GROUP BY a SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4), HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3; (SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
...@@ -2094,7 +2094,7 @@ SELECT a FROM t1 GROUP BY a ...@@ -2094,7 +2094,7 @@ SELECT a FROM t1 GROUP BY a
SELECT a FROM t1 GROUP BY a SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4), HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b)) > 3; (SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b)) > 3;
--sorted_result
SELECT a FROM t1 SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2), ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)); (SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
...@@ -2102,7 +2102,7 @@ SELECT a FROM t1 ...@@ -2102,7 +2102,7 @@ SELECT a FROM t1
SELECT a FROM t1 SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1), ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b)); (SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
--sorted_result
SELECT a FROM t1 SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4), ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)); (SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
......
...@@ -18,7 +18,6 @@ drop procedure if exists set_all_columns_nullable; ...@@ -18,7 +18,6 @@ drop procedure if exists set_all_columns_nullable;
create table t1 (a1 char(8), a2 char(8), a3 char(8), a4 int); create table t1 (a1 char(8), a2 char(8), a3 char(8), a4 int);
insert into t1 values ('1 - 00', '2 - 00', '3 - 00', 0); insert into t1 values ('1 - 00', '2 - 00', '3 - 00', 0);
insert into t1 values ('1 - 01', '2 - 01', '3 - 01', 1); insert into t1 values ('1 - 01', '2 - 01', '3 - 01', 1);
insert into t1 values ('1 - 02', '2 - 02', '3 - 02', 2);
create table t2 (b1 char(8), b2 char(8), b3 char(8), b4 int); create table t2 (b1 char(8), b2 char(8), b3 char(8), b4 int);
insert into t2 values ('1 - 01', '2 - 01', '3 - 01', 1); insert into t2 values ('1 - 01', '2 - 01', '3 - 01', 1);
...@@ -151,6 +150,8 @@ call set_all_columns_not_null(); ...@@ -151,6 +150,8 @@ call set_all_columns_not_null();
call set_all_columns_nullable(); call set_all_columns_nullable();
insert into t1 values ('1 - 02', '2 - 02', '3 - 02', 2);
-- echo /****************************************************************************** -- echo /******************************************************************************
-- echo 2. Materialization is OFF, in-to-exists is ON, materialization is cheaper. -- echo 2. Materialization is OFF, in-to-exists is ON, materialization is cheaper.
-- echo ******************************************************************************/ -- echo ******************************************************************************/
......
# #
# Run subselect.test without semi-join optimization (test materialize) # Run subselect.test without semi-join and materialization optimizations
# # (test in-to-exists)
set optimizer_switch='materialization=off,semijoin=off'; set optimizer_switch='materialization=off,semijoin=off';
--source t/subselect.test --source t/subselect.test
......
...@@ -311,7 +311,7 @@ FROM t0 ...@@ -311,7 +311,7 @@ FROM t0
WHERE varchar_nokey IN ( WHERE varchar_nokey IN (
SELECT t1 .varchar_key from t1 SELECT t1 .varchar_key from t1
); );
--disable_parsing # wrong duplicate results - LP BUG#702374
SELECT t0.int_key SELECT t0.int_key
FROM t0 FROM t0
WHERE t0.varchar_nokey IN ( WHERE t0.varchar_nokey IN (
...@@ -325,7 +325,7 @@ WHERE t0.varchar_nokey IN ( ...@@ -325,7 +325,7 @@ WHERE t0.varchar_nokey IN (
SELECT t1_1 .varchar_key SELECT t1_1 .varchar_key
FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key
); );
--enable_parsing
DROP TABLE t0, t1, t2; DROP TABLE t0, t1, t2;
--echo # End of bug#46550 --echo # End of bug#46550
......
#
# Run subselect_sj2.test with subquery materialization.
#
set optimizer_switch='materialization=on';
--source t/subselect_sj2.test
set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
...@@ -3691,7 +3691,7 @@ bool JOIN::choose_subquery_plan(table_map join_tables) ...@@ -3691,7 +3691,7 @@ bool JOIN::choose_subquery_plan(table_map join_tables)
double outer_lookup_keys; double outer_lookup_keys;
/* Cost and row count of the unmodified subquery. */ /* Cost and row count of the unmodified subquery. */
double inner_read_time_1, inner_record_count_1; double inner_read_time_1, inner_record_count_1;
/* Cost and row count of the subquery with injected IN-EXISTS predicates. */ /* Cost of the subquery with injected IN-EXISTS predicates. */
double inner_read_time_2; double inner_read_time_2;
/* The cost to compute IN via materialization. */ /* The cost to compute IN via materialization. */
double materialize_strategy_cost; double materialize_strategy_cost;
...@@ -3756,7 +3756,7 @@ bool JOIN::choose_subquery_plan(table_map join_tables) ...@@ -3756,7 +3756,7 @@ bool JOIN::choose_subquery_plan(table_map join_tables)
if (reopt_result == REOPT_ERROR) if (reopt_result == REOPT_ERROR)
return TRUE; return TRUE;
/* inner_read_time_2 above is a dummy, get the correct total join cost. */ /* Get the cost of the modified IN-EXISTS plan. */
inner_read_time_2= inner_join->best_read; inner_read_time_2= inner_join->best_read;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment